home *** CD-ROM | disk | FTP | other *** search
- /*
- * You may freely copy, distribute and reuse the code
- * in this example. Scott Anguish disclaims any warranty of
- * any kind, expressed or implied, as to its fitness
- * for any particular use.
- * Please keep this notice intact
- * Written by: Scott Anguish sanguish@digifix.com
- */
-
- #import "MMFolderCell.h"
-
- #import <libc.h> /* MAXPATHLEN */
- #import <stdio.h>
- #import <strings.h>
-
- #import <appkit/appkit.h>
-
- #import <streams/streams.h>
-
-
- @implementation MMFolderCell:MMCell
-
- - imageFromFilename:(const char *)filename
- {
- char *tiff;
- int length;
- int okFlag;
- NXStream *localStream;
- id speaker = [NXApp appSpeaker];
-
-
- if (!theImage)
- {
- [speaker setSendPort: NXPortFromName(NX_WORKSPACEREQUEST, NULL)];
- [speaker getFileIconFor:filename TIFF:&tiff TIFFLength:&length ok:&okFlag];
- if (okFlag){
- localStream = NXOpenMemory(tiff, length, NX_READONLY);
- theImage = [[NXImage alloc] initFromStream: localStream ];
- NXCloseMemory(localStream, NX_FREEBUFFER);
- } else
- {
- theImage = [[NXImage alloc]
- initFromFile: "/usr/lib/nib/folder_nib.tiff" ];
- }
- } return self;
-
- }
-
- - imageFromAttachment
- {
-
- char filename[MAXPATHLEN+1];
-
- sprintf(filename,"/tmp/%s",attachmentName);
- [self imageFromFilename:filename];
- return self;
- }
-
-
- @end
-